package com.zs.netlibrary;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import com.zs.netlibrary.http.NetWorkUtils;
import com.zs.netlibrary.http.result.ResultCallback;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/17.
 */

public class TestActivity extends Activity{
    TextView request, response;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_net_test);
        request = (TextView) findViewById(R.id.tv_request);
        response = (TextView) findViewById(R.id.tv_response);
        request.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String url = "http://api.budejie.com/api/api_open.php";
                Map<String, String> map = new HashMap<String, String>();
                map.put("a", "list");
                map.put("c", "data");
                NetWorkUtils.postForm(url, map, new ResultCallback() {
                    @Override
                    public void onResponse(String data) {
                        super.onResponse(data);
                        response.setText(data);
                    }

                    @Override
                    protected void onDataFine(JSONObject jsonObject) {
                        Log.e("onDataFine","");
                    }

                    @Override
                    public void onDataFine(JSONArray jsonArray) {
                        super.onDataFine(jsonArray);

                    }
                });
            }
        });


    }
}
